//
//  secondTableViewCell.m
//  Protect -A
//
//  Created by 付剑英 on 16/6/16.
//  Copyright © 2016年 付剑英. All rights reserved.
//

#import "secondTableViewCell.h"
#import "baseLabel.h"
#import "baseImageView.h"
#import <Masonry.h>
@interface secondTableViewCell()
@property (nonatomic,retain)baseLabel *labelname;//图标名字
@property (nonatomic,retain)baseImageView *imageview1;//图片
@property (nonatomic,retain)baseLabel *labelcontent;//内容
@property (nonatomic,retain)baseLabel *labelpriceing;//现价
@property (nonatomic,retain)baseLabel *labelprice;//原价
@end

@implementation secondTableViewCell

//内存管理
-(void)dealloc{
    [self.imageview1 release];
    [self.labelcontent release];
    [self.labelpriceing release];
    [self.labelname release];
    [self.labelprice release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self create];
    }
    return self;
}

-(void)create{
    
    self.imageview1 = [[baseImageView alloc]init];
    [self.contentView addSubview:self.imageview1];
    
    self.labelname = [[baseLabel alloc]init];
    [self.contentView addSubview:self.labelname];
    
    self.labelpriceing = [[baseLabel alloc]init];
    [self.contentView addSubview:self.labelpriceing];
    
    self.labelcontent = [[baseLabel alloc]init];
    [self.contentView addSubview:self.labelcontent];
    
    self.labelprice = [[baseLabel alloc]init];
    [self.contentView addSubview: self.labelprice];
    
    [self.imageview1 release];
    [self.labelcontent release];
    [self.labelpriceing release];
    [self.labelname release];
    [self.labelprice release];
    
    self.imageview1.backgroundColor = [UIColor redColor];
    self.labelname.backgroundColor = [UIColor yellowColor];
    self.labelcontent.backgroundColor = [UIColor greenColor];
    self.labelpriceing.backgroundColor = [UIColor blackColor];
    self.labelprice.backgroundColor = [UIColor blackColor];
}

-(void)layoutSubviews{
  
    
    //图片距离content 上为10 左右为0
    [self.imageview1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.contentView).offset(0);
        make.right.mas_equalTo(self.contentView).offset(0);
        
        make.bottom.mas_equalTo(self.labelname.mas_top).offset(-5);
    }];
    
    //名字距离imageview左右为0
    [self.labelname mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.imageview1);
        make.height.mas_equalTo(30);
        make.bottom.equalTo(self.labelcontent.mas_top).offset(-5);
    }];
    
    //内容距离名字labelname左右一样
    [self.labelcontent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.labelname);
        make.height.mas_equalTo(self.labelname);
        make.bottom.mas_equalTo(self.labelpriceing.mas_top).offset(-5);
    }];
    
    //现在价格
    
    [self.labelpriceing mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10);
        make.height.mas_equalTo(20);
        make.bottom.mas_equalTo(self.contentView).offset(-5);
        make.width.mas_equalTo(80);
    }];
    
    //原价
    
    [self.labelprice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.labelpriceing).offset(100);
        make.height.equalTo(self.labelpriceing);
        make.width.equalTo(self.labelpriceing);
        make.bottom.mas_equalTo(self.contentView).offset(-5);
    }];
    

}








@end
